//
//  CXBaseViewController.m
//  ChangZhouInHand
//
//  Created by dllo on 15/10/22.
//  Copyright © 2015年 巢鑫. All rights reserved.
//

#import "CXBaseViewController.h"
#import "AFNetworking.h"

@interface CXBaseViewController ()


@end

@implementation CXBaseViewController

#pragma mark - 网络状态
+ (void)networkReachabilityStatus:(JSONBLOCK)block
{
    // 网络连接检测封装
    AFNetworkReachabilityManager *reachManeger = [AFNetworkReachabilityManager sharedManager];
    // 开始检测
    [reachManeger startMonitoring];
    
    [reachManeger setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusNotReachable:
                block(@0);
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                block(@1);
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                block(@2);
                break;
            case AFNetworkReachabilityStatusUnknown:
                block(@(-1));
                break;
            default:
                break;
        }
    }];
    //        [reachManeger stopMonitoring];
    
}


//计算文本高度的方法
+ (CGFloat)heightWithText:(NSString *)text fontSize:(CGFloat)fontsize Width:(CGFloat)width

{
    //设置一个字典 保存文本属性
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]};
    
    //预设尺寸 文本最大不会超过这个范围
    CGSize size = CGSizeMake(width, 2000);
    //根据文本信息 计算得到一个CGRect
    //参数1. 尺寸范围
    //参数2. 获取文本尺寸的方式
    //参数3. 文本属性
    //参数4. 无用信息(上下文)
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
